import ts from "rollup-plugin-typescript2"; // 解析 ts
import { nodeResolve } from "@rollup/plugin-node-resolve"; // 解析第三方模块
import serve from "rollup-plugin-serve"; // 启动本地服务
const path = require("path");

// rollup 支持 es6 语法
export default {
  input: "src/index.ts",
  output: {
    format: "iife", // 打包成立即执行函数
    file: path.resolve(__dirname, "dist/bumdle.js"),
    sourcemap: true,
  },
  plugins: [
    // 第三方文件解析
    nodeResolve({
      extensions: [".js", ".ts"],
    }),
    // 指定配置文件
    ts({
      tsconfig: path.resolve(__dirname, "tsconfig.json"),
    }),
    serve({
      openPage: "/public/index.html",
      contentBase: "",
      port: 8089,
    }),
  ],
};
